<?php
namespace app\admin\model;

use think\Model;

class Order extends Model
{


    public function searchStartAddtimeAttr($q,$v,$d)
    {
        $q->where('addtime','> time',$v);

    }

    public function searchEndAddtimeAttr($q,$v,$d)
    {
        $q->where('addtime','< time',$v);
    }


    public function searchMinpriceAttr($q,$v,$d)
    {
        $q->where('price','>=',$v);
    }
    public function searchMaxpriceAttr($q,$v,$d)
    {
        $q->where('price','<=',$v);
    }

    public function searchOrderSnAttr($q,$v,$d)
    {
        $q->where('order_sn','like',"%{$v}%");
    }

    public function searchOrderStatusAttr($q,$v,$d)
    {
        $q->where('status','in',$v);
    }



    public static function orderList($where,$one)
    {
        return Order::table('ecm_order')
            ->withSearch(array_keys($where),$where)
            ->join('ecm_order_status','ecm_order.status=ecm_order_status.status_id')
            ->paginate(['list_rows'=>2,'query'=>$one]);
    }
}